package com.trade;

import lombok.extern.log4j.Log4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.MultipartConfigFactory;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.servlet.MultipartConfigElement;
import javax.servlet.http.HttpServletResponse;

/**
 * Class Description:程序总入口
 *
 * @Version v1.0 2017/4/21 1:07
 * @JDK version 1.8.0_51
 * @Author zfb
 */
@Log4j
@EnableTransactionManagement //开启事务配置
@EnableScheduling //开启定时任务扫描
@EnableAsync  //开启异步调用
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    /**
     * 文件上传受管bean
     * @return MultipartConfigElement
     */
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize("1024MB");
        factory.setMaxRequestSize("1024MB");
        return factory.createMultipartConfig();
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    /**
     * 应用启动方法
     */
    public static void main(String[] args) {
        log.info("*********************天空之城管理系统正在启动中，请稍候。*********************");
        SpringApplication.run(Application.class);
        log.info("*********************天空之城管理系统启动完毕****************************");
    }

}
